<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/2/7 0007
 * Time: 下午 15:05
 */

/**
 * 图片上传函数
 */
function uploadfile($pic,$path){
    $image = C('IMAGE_CONFIG');
    $upload = new \Think\Upload();
    $upload->maxSize = $image['MAXSIZE'];
    $upload->exts = $image['EXTS'];
    $upload->rootPath = $image['ROOTPATH'];
    $upload->savePath = $path .'/';
    // 上传时指定一个要上传的图片的名称，否则会把表单中所有的图片都处理，之后再想其他图片时就再找不到图片了
    if($info = $upload->upload(array($pic=>$_FILES[$pic]))) {
        $ret = $info[$pic]['savepath'].$info[$pic]['savename'];
        return $ret;
    }else{
        return $arr = array(
            'type' => 0,
            'error' => $upload->getError()
        );


    }
}